<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-05 15:16:04
 * @LastEditTime: 2019-12-05 19:31:29
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../../css/base.css" />
    <script type="text/javascript" src="../../script/jquery.js"></script>
    <script type="text/javascript" src="../../script/vue.min.js"></script>
    <script type="text/javascript" src="../../script/vant.min.js"></script>
    <script type="text/javascript" src="../../script/fastclick.js"></script>
    <script type="text/javascript" src="../../script/base.js"></script>
    <style type="text/css">

    </style>
</head>

<body>
    <div id="app" v-cloak>


        <van-popup v-model="showSearch" round position="bottom" :close-on-click-overlay="false" @click-overlay="closeFrame">
            <div>
                <van-cell title="时间" :value="searchData.S_SDate" @click="openDate(1)">
                </van-cell>
                <!-- <van-cell title="结束时间" :value="searchData.S_EDate" @click="openDate(2)">
                </van-cell> -->
            </div>
            <div class="btn-padding">
                <van-button type="primary" block style="border-radius: 0;" @click="searchList">查询</van-button>
            </div>
        </van-popup>


        <van-popup v-model="showDate" round position="bottom">
            <van-datetime-picker v-model="currentDate" type="date" @confirm="confirmDate" @cancel="cancelDate"
                cancel-button-text="清空" />
        </van-popup>


    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {
        //$('.init-full').show();

        var userInfo = FLD.getUserInfo();

        vm = new Vue({
            el: '#app',
            data: {
                showSearch: true,
                currentDate: new Date(),
                showDate: false,
                searchData: {
                    S_SDate: FLD.getFormatDate().split(' ')[0],
                    S_EDate: ''
                }

            },
            created: function () {

            },
            methods: {
                closeFrame(){
                    api.setFrameAttr({
                        name: 'visitRecordSearch',
                        hidden: true
                    });
                },
                searchList() {
                    var that = this;
                    api.sendEvent({
                        name: 'searchVisitList',
                        extra: {
                            date:that.searchData.S_SDate
                        }
                    });
                    api.setFrameAttr({
                        name: 'visitRecordSearch',
                        hidden: true
                    });
                },
                // openScreen(type, index) {
                //     var obj = {
                //         S_Type: index,
                //         S_Cont: '',
                //         S_BranchID: userInfo.S_BranchID,
                //         S_SXZ: '',
                //         S_StockID: userInfo.S_StockID,
                //         S_CargoID: userInfo.S_CargoID,
                //         S_BarCode: '',
                //         S_PriceN: 0,
                //         S_ProductID: 0
                //     }

                //     api.openWin({
                //         name: '筛选' + index,
                //         url: 'common/baseScreen.html',
                //         reload: true,
                //         slidBackEnabled: false,
                //         pageParam: {
                //             filterData: obj,
                //             type: type,
                //             allowClear: true
                //         }
                //     })

                // },
                openDate(index) {
                    dateIndex = index;
                    this.currentDate = new Date()
                    this.showDate = true;
                },
                confirmDate(value) {
                    if (dateIndex == 1) {
                        this.searchData.S_SDate = FLD.getFormatDate(value).split(' ')[0]
                    } else {
                        this.searchData.S_EDate = FLD.getFormatDate(value).split(' ')[0]
                    }
                    this.showDate = false;
                },
                cancelDate(value) {
                    if (dateIndex == 1) {
                        this.searchData.S_SDate = ''
                    } else {
                        this.searchData.S_EDate = '';
                    }
                    this.showDate = false;
                },
                onClickLeft() {
                    api.closeWin();
                }
            }
        })
    };
</script>

</html>